home *** CD-ROM | disk | FTP | other *** search
Wrap
/* SignArch v1.1, should be viewed with a tabsize of four */ /* SignArch, message digests a list of files, and archives everything Copyright (C) 1994 Jens T. Berger Thielemann This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. To contact the author: <jensthi@ifi.uio.no> or Jens Berger Spektrumveien 4 N-0666 Oslo Norway or Send a message in POST to J. BERGER on Trashcan (A)BBS [(+47) 22 25 74 78 or (+47) 22 25 88 22]. $VER: SignArch 1.1 (16.12.94) Copyright © 1994 Jens T. Berger Thielemann */ Signal On Break_c Signal On Break_d Say "SignArch v1.1 (C) 1994-95 Jens T. Berger Thielemann, <jensthi@ifi.uio.no>" _waitforreturn = 0 Address Command "ChkDate" DateIsValid = rc If DateIsValid ~= 0 Then Do Until DateIsValid = 0 Say "" Address Command "Date" Say "" Say "THE DATE ABOVE IS NOT CORRECT. Thus, a false time-issue would" Say "have been created. Please enter correct date below, syntax" Say "DD-MMM-YY." Address Command "Date ?" Address Command "ChkDate" DateIsValid = rc End /* * * Check that we're running under at least 2.0 * */ Time('R') Options Failat 21 Options Results Address Command "Version >nil: exec.library 37" If rc > 0 Then Do Say "***ERROR: Needs Kick 2.0!" Exit End /* * * Our task pointer is unique, if it can't be obtained, we will * get write access on the file below, and thus ensure that nobody * else is able to open the file simultaneously, and thus that * conflict with temporary files is avoided. * */ AddLib('rexxsupport.library',0,-30,0) If Show("Libraries","rexxsupport.library") Then Do Address ExecBase = import("0000 0004"X, 4) ThisTask = c2x(import(offset(execbase,276),4)) UniqueID = ThisTask Address UniqueID = Strip(UniqueID) End Else Do If Open('saisrunning', "T:SignArch is running!", 'W') = 0 Then Do Say "***ERROR: Another copy of SignArch is already running!" Call Quit End Else UniqueID = "" End pgpcommand = "PGP" md5command = "MD5Sum" lhacommand = "LhA" /* Trace ?ACEILRS */ If Open('pgpenv', "ENV:SignArchGUIPaths", 'R') Then Do Do While Eof('pgpenv') = 0 tmpline = ReadLn('pgpenv') If Left(Upper(tmpline), 4) = "PGP:" Then pgpcommand = Right(tmpline, Length(tmpline)-4) If Left(Upper(tmpline), 4) = "LHA:" Then lhacommand = Right(tmpline, Length(tmpline)-4) If Left(Upper(tmpline), 4) = "MD5:" Then md5command = Right(tmpline, Length(tmpline)-4) If Left(Upper(tmpline), 4) = "SMI:" Then Do If Strip(Upper(Right(tmpline, Length(tmpline)-4))) = "TRUE" Then sumfileicon = 1 End End Close('pgpenv') End /* * * Get the name of the CommandFile * */ Parse Arg FILELIST filelist = Strip(filelist) /* Show some info & ask for name of CommandFile if requested */ If filelist = "" | filelist = "?" Then Do Say "" Say "Message digests a list of files, and archives everything. Useful to avoid" Say "tampering of distributed files." Say "" Say "SignArch comes with ABSOLUTELY NO WARRANTY; details on this and" Say "distribution conditions in the GNU General Public License file." Say "To contact the author, write to:" Say "Jens Berger, Spektrumvn. 4, N-0666 Oslo, Norway." Say "or send a message in POST to J. BERGER on Trashcan (A)BBS" Say "[(+47) 22 25 74 78 or (+47) 22 25 88 22]." Say "" AddLib("rexxreqtools.library", 0, -30, 0) /* Use reqtools if possible */ If Show("Libraries","rexxreqtools.library") Then Do filelist = rtfilerequest( , , "Select filelist", , "rtfi_flags = freqf_patgad" , ) If rtresult = 0 Then Do Say "***ERROR: No filelist picked!" Call Quit End End Else Do Options Prompt "FILELIST/A: " Pull filelist filelist = Strip(filelist) End If filelist = "" Then Call Quit End /* * * Various variables are initialized here * */ Address Command "Delete >nil: T:"||UniqueID||"SaKeyFile" Address Command "Delete >nil: T:"||UniqueID||"SaSigFile" Address Command "Delete >nil: T:"||UniqueID||"SaTmpFile" Address Command "Delete >nil: T:"||UniqueID||"SaListFile" Address Command "Delete >nil: T:"||UniqueID||"SaWTmpFile" Address Command "Delete >nil: T:"||UniqueID||"SaWildFile" /* Get the name of the current directory */ Address Command "Cd >T:"||UniqueID||"SACDFile" If Open('curdir', "T:"||UniqueID||"SaCDFile", 'R') = 1 Then Do CurDir = Readln('curdir') Pragma("Directory", CurDir) Close('curdir') End Say "" ret = Open('flfile', FILELIST, 'R') If ret = 0 Then Do Say "***ERROR: Unable to open FileList file!" Call Quit End If Strip(ReadLn('flfile')) ~= "!!FILELIST!!" Then Do Say "***ERROR: This file is not a filelist file, as the first line is not `!!FILELIST!!'" Call Quit End binchar = "" ascchar = "" id = "" bannum = 0 commnum = 0 sumicon = 0 endwait = 0 cryptfile = 0 dontaddkey = 0 waittype = "" rootdir = "" deepchk = "" inctext = "" arcwipe = "w" addarmor = "" fileforced = 0 wildcards = 1 sumonly = 0 /* * * Read the CommandFile line by line, and parse the commands/options * */ Say "Parsing options..." lineread = ReadLn('flfile') Do While (Left(lineread, 3) = "***" | Left(lineread, 1) = ";" | lineread = "") & Eof('flfile') = 0 & fileforced = 0 Parse Var lineread type dummy If Left(lineread, 3) = "***" & lineread ~= "" Then Do If Length(lineread) > 11 Then Do data = Right(lineread, Length(lineread)-11) data = Strip(data) data = Strip(data, 'B', '"') data = '"'||data||'"' End Else data = "" type = Upper(Strip(type)) Select When type = "***ADDARMOR" Then Do addarmor = "a" Say "Option enabled : Final file will be ASCII-fied" End When type = "***ADDCOMM" Then Do If data ~= "" Then Do command.commnum = Strip(Right(lineread, Length(lineread)-11)) Say "Command added : "command.commnum commnum = commnum+1 End Else Do Say "***ERROR: No parameter for ADDCOMM option!" Call Quit End End When type = "***ARCHIVE" Then Do ARCHIVE = data Say "Archive : "||ARCHIVE End When type = "***ARCLIVE" Then Do arcwipe = "" Say "Option enabled : Noncrypted archive will NOT be deleted." End When type = "***ASCCHAR" Then Do If data ~= "" Then Do ascchar = Left(Strip(data, 'B', '"'), 1) If ascchar = ";" | ascchar = "/" | ascchar = ":" | ascchar = "*" | ascchar = " " | ascchar = '"' | ascchar = binchar Then Do Say '***ERROR: "'||ascchar||'"is not allowed as forcing ASCII character.' Call Quit End If ascchar ~= "" Then Say 'Force ASCII char: '||ascchar End Else Say 'Force ASCII char : None' End When type = "***AUTOCHK" Then Do autochk = 0 Say "Option enabled : The sum-file will be added commands, making it an" Say " AmigaDos script which will automatically check whether" Say " the files have been tampered, including itself. Note" Say " that this is a MAJOR security hole, read docs for more" Say " info." If Open('chkconf', "ENV:SignArchOpts", 'R') Then Do If Upper(ReadLn('chkconf')) = "DO_NOT_ASK_FOR_CONFIRMATION_OF_AUTOCHK" Then Do autochk = 1 End End If autochk = 0 Then Do AddLib("rexxreqtools.library", 0, -30, 0) If Show("Libraries","rexxreqtools.library") Then Do rtresult = rtezrequest("Do you really wish to add a self-checking script? This" || '0A'X || "is a MAJOR security hole - read the docs!","_Yes|_No", "SignArch Warning", "rtez_defaultresponse=0") If rtresult = 1 Then autochk = 1 End Else Do Say "" Say "Do you really wish to add a self-checking script? This" Options Prompt "is a MAJOR security hole - read the docs! (y/N)" Pull result If Upper(Strip(result)) = "Y" Then autochk = 1 End End If autochk = 0 Then Say "***NOTE: Self-checking script will NOT be added." End When type = "***BANNERS" Then Do If data ~= "" Then banner.bannum = '"'||Right(lineread, Length(lineread)-11)||'"' If bannum = 0 Then Say "Banner:" Address Command "Echo "||banner.bannum bannum = bannum + 1 End When type = "***BINCHAR" Then Do If data ~= "" Then Do binchar = Left(Strip(data, 'B', '"'), 1) If binchar = ";" | binchar = "/" | binchar = ":" | binchar = "*" | binchar = " " | binchar = '"' | binchar = ascchar Then Do Say '***ERROR: "'||binchar||'"is not allowed as forcing binary character.' Call Quit End If binchar ~= "" Then Say 'Force bin. char : '||binchar End Else Say 'Force bin. char : None' End When type = "***DEEPCHK" Then Do deepchk = "WHOLEFILE" Say "Option enabled : Entire file scanned when checking whether a file is ASCII." End When type = "***ENCRYPT" Then Do If cryptfile = 0 Then Do Say "Option enabled : Final archive will be encrypted." If Open('cryptnames', "T:"||UniqueID||"SACryptFile", 'W') = 0 Then Do Say "***ERROR: Unable to open workfile!" Call Quit End End cryptfile = 1 If data = "" Then Do Say "***ERROR: No name to encrypt to!" Call Quit End WriteLn('cryptnames', data) Say "Encrypt to : "||data End When type = "***ENDWAIT" Then Do endwait = 1 Say "Option enabled : Wait command only issued at end of checking-script." End When type = "***EXECCMD" Then Do If data ~= "" Then Do Options Failat 500 data = Strip(Right(lineread, Length(lineread)-11)) Say "Executing cmd. : "||data Address Command data If RC ~= 0 Then Do AddLib("rexxreqtools.library", 0, -30, 0) If Show("Libraries","rexxreqtools.library") Then Do rtresult = rtezrequest(data||"' failed returncode "||RC||'0A'X||"Continue?","_Yes|_No", "SignArch Warning", "rtez_defaultresponse=0") If rtresult = 0 Then Call Quit End Else Do Say "" Say "***'"||data||"' failed returncode "||RC Options Prompt "***Continue (Y/n)? " Pull result If Upper(Strip(result)) = "N" Then Call Quit End End Options Failat 21 End Else Do Say "***ERROR: No parameter given to EXECCMD option!" Call Quit End End When type = "***INCTEXT" Then Do If data ~= "" Then Do inctext = Strip(data, 'B', '"') Say "Include textfile: "||data End Else Do Say "***ERROR: No name specified for text to be included!" Call Quit End End When type = "***LASTOPT" Then Do fileforced = 1 Say "***Forcing option parsing complete..." Say "" End When type = "***NOKEYADD" Then Do dontaddkey = 1 Say "Option enabled : Your PGP key will NOT be added to the sumfile" End When type = "***NOWILDS" Then Do wildcards = 0 End When type = "***ROOTDIR" Then Do rootdir = Strip(data, 'B', '"') Say 'Rootdir set to : "'||rootdir||'"' If Pragma("Directory", rootdir) = 0 Then Do Say "***ERROR: Unable to set rootdir!" Call Quit End End When type = "***SIGNAME" Then Do If data ~= "" Then Do ID = data Say "Your ID/name : "||ID End Else Say "No parameter given for SIGNAME option!" End When type = "***SUMFILE" Then Do SUMFILE = data Say "Msg. digest file: "||SUMFILE Address Command 'Delete >nil: '||SUMFILE End When type = "***SUMICON" Then Do sumicon = 1 Say "Option enabled : Icons will be summed." End When type = "***SUMONLY" Then Do sumonly = 1 Say "Option enabled : No archiving will be done, only the sumfile will be created." End When type = "***WAITCOM" Then Do If data ~= "" Then Do waittype = Strip(Right(lineread, Length(lineread)-11)) Say "Wait command : "||waittype End Else Do waittype = "" Say "Option enabled : No waiting between commands" End End When type = "***WAITRET" Then Do _waitforreturn = 1 End Otherwise Do Say "***ERROR: Unknown option!" Call Quit End End End lineread = ReadLn('flfile') End Say "Option parsing complete..." Call Close('cryptnames') If rootdir = "" Then Do rootdir = curdir Say 'Rootdir is still: '||rootdir End /* * * Find the user's ID, via various methods * */ If id = "" Then Do ret = Open('pgppath', "ENV:PGPPATH", 'R') If ret ~= 0 Then Do pgppath = Strip(ReadLn('pgppath')) Close('pgppath') If Right(pgppath, 1) ~= ":" & Right(pgppath, 1) ~= "/" Then pgppath = pgppath||"/" /* First, look in the pgp.config file */ ret = Open('pgpconfig', pgppath||"config.txt", 'R') If ret = 0 Then ret = Open('pgpconfig', pgppath||"pgp.config", 'R') If Ret ~= 0 Then Do Do While Eof('pgpconfig') = 0 pgpline = Strip(ReadLn('pgpconfig')) If pgpline ~= "" & Left(pgpline, 1) ~= "#" Then Do If Abbrev(Upper(pgpline), "MYNAME") = 1 Then Do Do While Left(pgpline, 1) ~= "=" pgpline = Right(pgpline, Length(pgpline)-1) End pgpline = Right(pgpline, Length(pgpline)-1) pgpline = Strip(pgpline) If Index(pgpline, '#') ~= 0 Then Do Do While Right(pgpline, 1) ~= "#" pgpline = Left(pgpline, Length(pgpline)-1) End pgpline = Left(pgpline, Length(pgpline)-1) End pgpline = Strip(pgpline) pgpline = Strip(pgpline, 'B', '"') ID = '"'||pgpline||'"' Address Command pgpcommand||" >nil: -kv "||ID||" "||pgppath||"secring.pgp" If rc = 0 Then Do Say "Your ID/name : "||ID End Else Do Say "***WARNING: Fault in pgp.config/config.txt. MyName param not found in secring.pgp." Id = "" End End End End Close('pgpconfig') End Else Say "Unable to open pgp.config/config.txt file!" /* If the pgpconfig file isn't useful, just use the first key on the */ /* secret keyring */ If ID = "" Then Do Address Command pgpcommand||' >T:'||UniqueID||'SATmpFile -kv '||pgppath||'secring.pgp' If rc = 0 Then Do gotfirstid = 0 If Open('satmpfile', "T:"||UniqueID||"SATmpFile", 'R') Then Do Do Until Eof('satmpfile') = 1 pgpline = ReadLn('satmpfile') If Upper(Left(pgpline, 3)) = "SEC" Then Do gotfirstid = 1 Leave End End Close('satmpfile') End If gotfirstid = 1 Then Do Parse Var pgpline keytype keybits keydate ID Drop keytype keybits keydate ID = Strip(ID) ID = Strip(ID, 'B', '"') ID = '"'||ID||'"' Address Command pgpcommand||" >nil: -kv "||ID||" "||pgppath||"secring.pgp" If rc = 0 Then Do Say "Your ID/name : "||ID Close('pgpconfig') End Else Do Say "***ERROR: Unable to find your name!" Call Quit End End End End End Else Say "Unable to get env variable PGPPATH!" End FoundID: Say "" If Strip(Strip(id, 'B', '"')) = "" Then Do Say "***ERROR: Unable to get user ID!" Call Quit End If Strip(Strip(sumfile, 'B', '"')) = "" Then Do Say "***ERROR: Unable to find name of sumfile!" Call Quit End If Strip(Strip(archive, 'B', '"')) = "" & sumonly = 0 Then Do Say "***ERROR: Unable to find name of archive!" Call Quit End /* Make sure the sumfile exists */ Address Command 'Echo "Dummy" TO 'SUMFILE /* Get full path for it */ Address Command 'List >T:'||UniqueID||'SAWTmpFile '||SUMFILE||' LFORMAT %f%s' If Open('sawtmpfile', "T:"||UniqueID||"SAWTmpFile", 'R') Then Do sumfile = ReadLn('sawtmpfile') Close('sawtmpfile') End Else Do Say "***ERROR: Unable to get full sumfile name!" Call Quit End If sumfile = "" Then Do Say "***ERROR: Unable to examine sumfile! Empty dir?" Call Quit End Address Command 'Delete >nil: "'||SUMFILE||'"' /* Get the full path for the rootdir */ Address Command 'List >T:'||UniqueID||'SAWTmpFile LFORMAT %f' If Open('sawtmpfile', "T:"||UniqueID||"SAWTmpFile", 'R') Then Do fullrootdir = ReadLn('sawtmpfile') Close('sawtmpfile') End Else Do Say "***ERROR: Unable to get full root path name!" Call Quit End If fullrootdir = "" Then Do Say "***ERROR: Unable to examine rootdir! Empty dir?" Call Quit End /* Check that the sumfile is within (a subdir of) the rootdir */ If Left(sumfile, Length(fullrootdir)) = fullrootdir Then Do sumfile = Right(sumfile, Length(sumfile)-Length(fullrootdir)) End Else Do Say "***ERROR: You can't put the sumfile above the ROOTDIR!" Call Quit End /* Get the directory of the sumfile, relative to the rootdir */ sumdir = sumfile sumdir = Strip(sumdir) sumdir = Strip(sumdir, 'B', '"') If (Index(sumfile, "/") = 0 & Index(sumfile, ":") = 0) Then sumdir = "" Else Do While Right(sumdir, 1) ~= "/" & Right(sumdir, 1) ~= ":" & Length(sumdir) > 0 sumdir = Left(sumdir, Length(sumdir)-1) End sumdirlevels = Length(sumdir)-Length(Compress(sumdir,"/")) sumfilefile = Strip(sumfile, 'B', '"') sumfilefile = Strip(Right(sumfilefile, Length(sumfilefile)-Length(sumdir)), 'B', '"') If sumfilefile = "" Then Do Say "***ERROR: No filename for sumfile!?!?!" Call Quit End If Open('satmpfile', "T:"||UniqueID||"SaTmpFile", 'W') = 0 Then Do Say "***ERROR: Unable to open temporary file!" Call Quit End /* "Avoid" a bug in PGP */ WriteLn('satmpfile', "; /*** CLEARSIGNED MESSAGE BEGINS HERE, ALL DATA ABOVE MUST BE IGNORED ***/") If commnum > 0 Then Do Do count = 0 To commnum-1 WriteLn('satmpfile',command.count) End If autochk = 0 Then Writeln('satmpfile', "Quit") End /* Create necessary files and lines for self-checking script */ If autochk = 1 Then Do If Open('beginfile', sumdir||"-----BEGIN", 'W') Then Do Sftlen = (Length(Sumfilefile)+8)%4 If SftLen > 255 Then Do Say "***ERROR: Length of sumfile name too long! Aborting!" Call Quit End SftLen = D2C(SftLen) Say "Creating dummy file to avoid self-check script failure..." /* For a disassembly of this, look in the Source directory */ WriteCh('beginfile', '000003F3 00000000 00000002 00000000 00000001'X) WriteCh('beginfile', '0000004B 000000'X) WriteCh('beginfile', SftLen) WriteCh('beginfile', '000003E9 0000004B 7E142C78 000443FA 00CC4EAE'X) WriteCh('beginfile', 'FE684A80 67000084 2C407E0A 223AFFE2 D281D281'X) WriteCh('beginfile', '58812C01 243C0000 03ED4EAE FFE22800 67284FEF'X) WriteCh('beginfile', 'FFD82200 240F7624 4EAEFFD6 B6806620 204F43FA'X) WriteCh('beginfile', '00687423 1018B019 661C51CA FFF87E00 602841FA'X) WriteCh('beginfile', '0084487A 002C6012 41FA008F 487A001C 600841FA'X) WriteCh('beginfile', '009F487A 000E6122 2046611E 41FA00AB 60184FEF'X) WriteCh('beginfile', '00282204 4EAEFFDC 224E2C78 00044EAE FE622007'X) WriteCh('beginfile', '4E752408 76FF4A18 57CBFFFC 46834EAE FFC42200'X) WriteCh('beginfile', '4EEEFFD0 2D2D2D2D 2D424547 494E2050 47502053'X) WriteCh('beginfile', '49474E45 44204D45 53534147 452D2D2D 2D2D0A0A'X) WriteCh('beginfile', '646F732E 6C696272 61727900 43616E27 74206F70'X) WriteCh('beginfile', '656E2073 756D6669 6C652022 0043616E 27742072'X) WriteCh('beginfile', '65616420 66726F6D 2073756D 66696C65 20220043'X) WriteCh('beginfile', '4845434B 20464149 4C454420 494E2053 554D4649'X) WriteCh('beginfile', '4C452022 00220A00 000003F2 000003EA 000000'X) WriteCh('beginfile', SftLen) WriteCh('beginfile', Sumfilefile) Sftlen = ((Length(Sumfilefile)+8)%4)*4 Count = Length(Sumfilefile) Do While Count < SftLen WriteCh('beginfile', '00'X) Count = Count + 1 End WriteCh('beginfile', '000003F2'X) Close('beginfile') End Else Do Say "***ERROR: Unable to create '-----BEGIN' file. Auto-checking script won't work." Call Quit End If bannum > 0 Then Do count = 0 To bannum-1 WriteLn('satmpfile',"Echo "||banner.count) End WriteLn('satmpfile','PGP -ka "'||SUMFILEFILE||'"') If waittype ~= "" & endwait = 0 Then WriteLn('satmpfile', waittype) WriteLn('satmpfile','PGP -o T:PGPTest.asc "'||SUMFILEFILE||'"') If waittype ~= "" & endwait = 0 Then WriteLn('satmpfile', waittype) WriteLn('satmpfile','MD5SUM -cv T:PGPTest.asc') WriteLn('satmpfile',"Delete >nil: T:PGPTest.asc") If waittype ~= "" Then WriteLn('satmpfile', waittype) WriteLn('satmpfile',"Quit") End Else Do If bannum > 0 Then Do count = 0 To bannum-1 WriteLn('satmpfile',banner.count) End End /* Include the "readme" file, if wanted */ If inctext ~= "" Then Do Address Command 'ChkASCII "'||inctext||'" WHOLEFILE' If rc ~= 0 Then Do If rc = 5 Then Say "***WARNING: Text to be included is not ASCII!" If rc = 20 Then Do Say "***ERROR: Could not check whether INCTEXT file is ASCII or binary!" Call Quit End End If Open('incfile', inctext, 'R') = 1 Then Do Say "Including file "||inctext||"..." WriteLn('satmpfile', "") WriteLn('satmpfile', "=== Included text file begins ===") WriteLn('satmpfile', "") WriteLn('satmpfile', "") Do Until Eof('incfile') = 1 incline = ReadLn('incfile') If WriteLn('satmpfile', incline) <= 0 Then Do Say "***ERROR: Unable to include file!" Call Quit End End WriteLn('satmpfile', "") WriteLn('satmpfile', "") WriteLn('satmpfile', "=== Included text file ends ===") WriteLn('satmpfile', "") Close('incfile') End End /* Write some informative lines... */ WriteLn('satmpfile',"") WriteLn('satmpfile',"=== File created using SignArch v1.1, © 1994 Jens T. Berger Thielemann. ===") WriteLn('satmpfile',"") WriteLn('satmpfile',"=== To check the contents of this file, change the current directory to ===") WriteLn('satmpfile',"=== to that of this file, and enter the following commands: ===") WriteLn('satmpfile',"") WriteLn('satmpfile','PGP -ka "'||SUMFILEFILE||'"') WriteLn('satmpfile','PGP -o T:PGPTest.asc "'||SUMFILEFILE||'"') WriteLn('satmpfile','MD5SUM -cv T:PGPTest.asc') WriteLn('satmpfile',"") If autochk = 1 Then Do WriteLn('satmpfile',"=== You may also just execute this file as a Shell script. ===") WriteLn('satmpfile',"") End WriteLn('satmpfile',"=== Signatures begin below ===") Close('satmpfile') icon = 0 forcechar = "" /* Trace ?ACEILRS */ /* Get the names of the files to archive */ If wildcards = 1 Then Do Say "Parsing wildcards..." If Open('sawildfile', "T:"||UniqueID||"SAWildFile", 'W') Then Do Do Until Eof('flfile') = 1 If Strip(lineread) ~= "" & Left(Strip(lineread), 1) ~= ";" Then Do lineread = Strip(Strip(lineread), 'B', '"') /* Take care of ASCCHAR/BINCHAR */ manylines = "" Select When Left(lineread, 1) = ascchar | Left(lineread, 1) = binchar Then Do forcechar = Left(lineread, 1) manylines = '"'||Right(lineread, Length(lineread)-1)||'"' Do Until Eof('flfile') = 1 | ( Strip(lineread) ~= "" & Left(Strip(lineread), 1) ~= ";" ) lineread = Strip(ReadLn('flfile')) lineread = Strip(Strip(lineread), 'B', '"') End End When Length(lineread) > 50 Then Do If lineread ~= "" & Left(Strip(lineread), 1) ~= ";" Then manylines = '"'||lineread'"' Do Until Eof('flfile') = 1 | ( Strip(lineread) ~= "" & Left(Strip(lineread), 1) ~= ";" ) lineread = Strip(ReadLn('flfile')) lineread = Strip(Strip(lineread), 'B', '"') End End Otherwise Do forcechar = "" Do While Left(lineread, 1) ~= ascchar & Left(lineread, 1) ~= binchar & Eof('flfile') = 0 & Length(manylines) < 400 & Length(lineread) < 50 If Strip(lineread) ~= "" & Left(Strip(lineread), 1) ~= ";" Then Do manylines = manylines||' "'||lineread||'"' End Do Until Eof('flfile') = 1 | ( Strip(lineread) ~= "" & Left(Strip(lineread), 1) ~= ";" ) lineread = Strip(ReadLn('flfile')) lineread = Strip(Strip(lineread), 'B', '"') End End End End Address Command 'List >T:'||UniqueID||'SAWTmpfile '||manylines||' LFORMAT %f%s ALL FILES' If rc = 0 Then Do If Open('sawtmpfile', "T:"||UniqueID||"SAWTmpFile", 'R') = 1 Then Do Do Until Eof('sawtmpfile') = 1 wildfile = ReadLn('sawtmpfile') If wildfile ~= "" Then Do If Left(wildfile, Length(fullrootdir)) = fullrootdir Then Do WriteLn('sawildfile', forcechar||Right(wildfile, Length(wildfile)-Length(fullrootdir))) Say " "||Right(wildfile, Length(wildfile)-Length(fullrootdir)) End Else Do Say "***ERROR: Files exist above rootdir!" Call Quit End End End Close('sawtmpfile') End Else Do Say "***ERROR: Unable to open temporary file!" Call Quit End End Else Do Say "***ERROR: Unable to get information for file "||lineread Call Quit End End Else Do lineread = Strip(ReadLn('flfile')) End End End Else Do Say "***ERROR: Unable to open temporary file!" Call Quit End End Else Do /* Trace ?ACEILRS */ Say "Copying filenames..." If Open('sawildfile', "T:"||UniqueID||"SAWildFile", 'W') Then Do Do Until Eof('flfile') = 1 If lineread ~= "" & Left(lineread, 1) ~= ";"Then Do If Left(lineread, Length(fullrootdir)) = fullrootdir Then Do WriteLn('sawildfile', forcechar||Right(lineread, Length(lineread)-Length(fullrootdir))) End Else Do Say "***ERROR: Files exist above rootdir!" Call Quit End End lineread = ReadLn('flfile') End End Else Do Say "***ERROR: Unable to open temporary file!" Call Quit End End If autochk = 1 Then Do Say Say "Adding dummy file to make sure the script works properly." WriteLn('sawildfile', SUMDIR||"-----BEGIN") End Close('flfile') Close('sawildfile') /* Trace ?ACEILRS */ If sumfileicon = 1 Then Do If Exists(Sumfile||".info") = 0 Then Do Say "Creating icon for sumfile..." If autochk = 1 | commnum > 0 Then Do Address Command 'Copy FROM ENV:sum_scr.info TO "'||Sumfile||'.info"' End Else Do Address Command 'Copy FROM ENV:sum_dta.info TO "'||Sumfile||'.info"' End End Address Command 'Search >nil: "T:'||UniqueID||'SAWildFile" "'||Sumfile||'.info" QUIET' If rc ~= 0 Then Do If Open('sawildfile', "T:"||UniqueID||"SAWildFile", 'A') Then Do Seek('sawildfile', 0, 'E') WriteLn('sawildfile', Sumfile||'.info') Close('sawildfile') End Else Do Say "***ERROR: Can't open temporary file!" Call Quit End End End If Open('flfile', "T:"||UniqueID||"SAWildFile", 'R') = 0 Then Do Say "***ERROR: Unable to open work file!" Call Quit End If Pragma("Directory", sumdir) = 0 Then Do Say "***ERROR: Unable to locate drawer of sum-file!" Call Quit End FoundSumFile = 0 Say "" If Open('salistfile', "T:"||UniqueID||"SAListFile", 'W') = 1 Then Do Do While Eof('flfile') = 0 fileline = ReadLn('flfile') If fileline ~= "" & Left(fileline, 1) ~= ";" Then Do fileline = Strip(fileline) fileline = Strip(fileline, 'B', '"') /* Take care of BINCHAR/ASCCHAR information */ Select When Left(fileline, 1) = binchar & binchar ~= "" Then Do fileline = Right(fileline, Length(fileline)-1) fileline = Strip(fileline, 'B', '"') Say "*** Forcing "||fileline||" to binary." cares = 5 forced = 1 tmpicon = 0 End When Left(fileline, 1) = ascchar & ascchar ~= "" Then Do fileline = Right(fileline, Length(fileline)-1) fileline = Strip(fileline, 'B', '"') Say "*** Forcing "||fileline||" to ASCII." cares = 0 forced = 1 tmpicon = 0 End Otherwise Do forced = 0 tmpicon = 1 End End /* Write the filename without ASCCHAR/BINCHAR information */ /* If the file begins with '-' one must add a '-' to the name */ If Left(fileline, 1) = '-' Then WriteLn('salistfile', "-"||fileline) Else WriteLn('salistfile', fileline) If Index(Upper(fileline), Upper(sumdir)) = 1 Then fileline = Right(fileline, Length(fileline)-Length(sumdir)) Else fileline = Copies("/", sumdirlevels)||fileline If sumicon = 0 | tmpicon = 1 Then Do icon = 0 If Upper(Right(fileline, 5)) = ".INFO" Then Do If Open('icon', fileline, 'R') ~= 0 Then Do magic = ReadCh('icon', 2) Close('icon') If magic = 'E310'X Then Do icon = 1 End End End End /* Trace ?ACEILRS */ fileline = '"'||Strip(fileline, 'B', '"')||'"' If Index(fileline, ":") ~= 0 Then Do Say "***WARNING: Root directory information is present in filename. End-user" Say "*** may experience trouble checking the message digests. You" Say "*** are strongly urged to remove this information from your file" Say "*** to avoid problems." End If (icon = 0 | tmpicon = 0) & (Upper(Strip(fileline, 'B', '"')) ~= Upper(SUMFILEFILE)) Then Do If forced = 0 Then Do Address Command 'ChkASCII FILENAME '||fileline||' '||deepchk cares = rc End If cares = 20 Then Do Say "***ERROR: ChkASCII could not check file "||fileline||"! File not found?" Close('salistfile') Call Quit End If Left(fileline, 2) = '"-' Then Do Say "***NOTE: Please ignore the next `Invalid argument' message." filetosum = '"" '||fileline hack = 1 End Else Do filetosum = fileline hack = 0 End If cares = 5 Then Do Say "Summing binary file "||fileline||"..." Address Command md5command||' >>T:'||UniqueID||'SaTmpFile -b '||filetosum If rc ~= 0 & (hack = 0 | Exists(Strip(fileline, 'B', '"')) = 0) Then Do Say "***ERROR: Could not sum file "||fileline||"!" Call Quit End End Else Do Say "Summing ASCII file "||fileline||"..." Address Command md5command||' >>T:'||UniqueID||'SaTmpFile '||filetosum If rc ~= 0 & (hack = 0 | Exists(Strip(fileline, 'B', '"')) = 0) Then Do Say "***ERROR: Could not sum file "||fileline||"!" Call Quit End End End Else Do If Upper(Strip(fileline, 'B', '"')) = Upper(SUMFILEFILE) Then Do FoundSumFile = 1 End End End End End If FoundSumFile = 0 Then WriteLn('salistfile', SUMFILE) Close('salistfile') /* We've created the file with message digests, now let's sign it */ Address Command pgpcommand||" -fast +CLEARSIG=ON +ARMORLINES=0 <T:"||UniqueID||"SATmpFile >T:"||UniqueID||"SASigFile -u "||ID cares = rc Say "" If Pragma("Directory", fullrootdir) = 0 Then Do Say "***ERROR: Unable to re-set dir to rootdir!" Call Quit End Success = FALSE If cares = 0 Then Do /* Add the PGP key */ If dontaddkey = 0 Then Do Address Command pgpcommand|| " -kxaf "||ID||" >T:"||UniqueID||"SAKeyFile" pgprc = rc End Else pgprc = 0 If pgprc = 0 Then Do Say "" If dontaddkey = 0 Then Address Command "Join T:"||UniqueID||"SASigFile T:"||UniqueID||'SAKeyFile TO "'||SUMFILE||'"' Else Address Command 'Copy T:'||UniqueID||'SASigFile TO "'||SUMFILE||'"' If rc = 0 Then Do If autochk = 1 | commnum ~= 0 Then Address Command 'Protect "'||SUMFILE||'" S ADD' If sumonly = 0 Then Do /* Make sure the archive has ".lha" as extension */ ARCHIVE = Strip(Archive, 'B', '"') Archive = Strip(Archive) /* Trace ? */ arcbody = Archive Do While Right(arcbody, 1) ~= "." & Length(arcbody) ~= 0 & Right(arcbody, 1) ~= "/" & Right(arcbody, 1) ~= ":" arcbody = Left(arcbody, Length(arcbody)-1) End If Length(arcbody) > 0 & Right(arcbody, 1) = "." Then arcbody = Left(arcbody, Length(arcbody)-1) If ArcBody = "" | Right(arcbody, 1) = "/" | Right(arcbody, 1) = ":" Then arcbody = Archive ArcExt = Right(Archive, Length(Archive) - Length(ArcBody)) If cryptfile = 1 | addarmor = "a" Then Do If Upper(arcext) ~= ".LZH" Then arcext = ".LZH" End Else Do If Upper(arcext) ~= ".LHA" Then arcext = ".LHA" End If Exists(arcbody||arcext) Then Address Command 'Delete "'||arcbody||arcext||'"' Address Command lhacommand||' -xa -iT:'||UniqueID||'SaListFile a "'||arcbody||arcext||'"' If rc = 0 Then Do Say "" Say "Archive & sum-file successfully created." success = TRUE If addarmor = "a" & cryptfile = 0 Then Do success = FALSE Address Command 'Delete <>nil: "'||ArcBody||'.as?"' Say "ASCII-fying archive..." Address Command pgpcommand||' -a -o "'||ArcBody||'" "'||ArcBody||ArcExt||'"' If rc = 0 Then Do Say "Archive successfully ASCII-fied." Arcext = ".asc" success = TRUE End End End Else Do Say "" Say "Something went wrong when creating archive." If cryptfile = 1 Then Do AddLib("rexxreqtools.library", 0, -30, 0) If Show("Libraries","rexxreqtools.library") Then Do rtresult = rtEZRequest("Creation of archive may have failed."||'0A'X||"Still try to encrypt?", "_Yes|_No", "SignArch ERROR", "rtez_defaultresponse=0") If rtresult = 0 Then Do Say "Exiting WITHOUT encrypting..." Call Quit End End Else Do Say "Creation of archive may have failed." Options Prompt "Still try to encrypt (y/N)? " Pull result If Upper(Strip(result)) ~= "Y" Then Do Say "Exiting WITHOUT encrypting..." Call Quit End End End End If cryptfile = 1 Then Do success = FALSE If Addarmor = "a" Then ArcExt = ".asc" Else ArcExt = ".pgp" If Exists(ArcBody||ArcExt) Then Address Command 'Delete "'||ArcBody||ArcExt||'"' Address Command pgpcommand||" -es"||ADDARMOR||ARCWIPE||" -u "||ID||' -o "'||ArcBody||ArcExt||'" "'||ArcBody||'.lzh" @T:'||UniqueID||'SACryptFile' If rc = 0 Then Do Say "Archive successfully encrypted." success = TRUE End Else Say "***ERROR: Unable to encrypt file!" End End Else Do Say "Sumfile successfully created." ArcBody = SumFile ArcExt = "" success = TRUE End End Else Say "***ERROR: Unable to create final sumfile!" End Else Say "***ERROR: Unable to extract your Public Key!" End Else Say "***ERROR: Unable to sign file with signatures!" If success = TRUE Then Do elapsed = Time('E') mins = elapsed % 60 secs = elapsed - (mins * 60) Say 'Final filename : '||ArcBody||ArcExt Say 'Operation succeeded in '||mins||' minute(s) and '||secs||' second(s).' _waitforreturn = 0 End Call Quit Break_c: Break_d: Say "Break signal detected. Exiting..." Quit: Call Close('flfile') Call Close('pgppath') Call Close('pgpconfig') Call Close('satmpfile') Call Close('sawtmpfile') Call Close('sawildfile') Call Close('salistfile') Call Close('cryptnames') Address Command "Delete >nil: T:"||UniqueID||"SaCryptFile T:"||UniqueID||"SaKeyFile T:"||UniqueID||"SaSigFile T:"||UniqueID||"SaTmpFile T:"||UniqueID||"SaListFile T:"||UniqueID||"SaWTmpFile T:"||UniqueID||"SaWildFile" If Open('curdir', "T:"||UniqueID||"SaCDFile", 'R') = 1 Then Do CurDir = Readln('curdir') Pragma("Directory", CurDir) Call Close('curdir') Address Command "Delete >nil: T:"||UniqueID||"SaCDFile" End Call Close('curdir') Call Close('saisrunning') Address Command 'Delete >nil: "T:SignArch is running!"' If _waitforreturn = 1 Then Do Options Prompt "Press <return> to continue..." Pull result End If Success = TRUE Then Exit Else Exit 10